<?php
    /*$cart = array(
        '0'=>array(
            'id'=>0,
            'category_id'=>0,
            'class'=>'nav-header',
            'description'=>'FEES',
            'amount'=>'COST',
            'paid'=>'PAID',
            'owed'=>'OWED',
            'button'=>'n'
        ),
        '1'=>array(
            'id'=>1,
            'category_id'=>0,
            'class'=>'',
            'description'=>'Academic Facility User Fee - Professional',
            'amount'=>200.00,
            'paid'=>100.00,
            'owed'=>100.00,
            'button'=>'y'
        ),
        '2'=>array(
            'id'=>2,
            'category_id'=>0,
            'class'=>'',
            'description'=>'Facility Subsidy Fee - Diploma',
            'amount'=>200.00,
            'paid'=>100.00,
            'owed'=>100.00,
            'button'=>'y'
        ),
        '3'=>array(
            'id'=>3,
            'category_id'=>0,
            'class'=>'',
            'description'=>'Facility Subsidy Fee - Degree',
            'amount'=>200.00,
            'paid'=>100.00,
            'owed'=>100.00,
            'button'=>'y'
        ),
        '4'=>array(
            'id'=>4,
            'category_id'=>0,
            'class'=>'',
            'description'=>'International Students Fee - Degree',
            'amount'=>200.00,
            'paid'=>100.00,
            'owed'=>100.00,
            'button'=>'y'
        ),
        '5'=>array(
            'id'=>5,
            'category_id'=>0,
            'class'=>'',
            'description'=>'International Students Fee - Diploma',
            'amount'=>200.00,
            'paid'=>100.00,
            'owed'=>100.00,
            'button'=>'y'
        ),
        '6'=>array(
            'id'=>6,
            'category_id'=>6,
            'class'=>'nav-header',
            'description'=>'ASSOCIATION FEES',
            'amount'=>'COST',
            'paid'=>'PAID',
            'owed'=>'OWED',
            'button'=>'n'
        ),
        '7'=>array(
            'id'=>7,
            'category_id'=>6,
            'class'=>'',
            'description'=>'Graduate Students Association Dues',
            'amount'=>200.00,
            'paid'=>100.00,
            'owed'=>100.00,
            'button'=>'y'
        ),
        '8'=>array(
            'id'=>8,
            'category_id'=>6,
            'class'=>'',
            'description'=>'Students Representative Council Dues',
            'amount'=>200.00,
            'paid'=>100.00,
            'owed'=>100.00,
            'button'=>'y'
        ),
        '9'=>array(
            'id'=>9,
            'category_id'=>6,
            'class'=>'',
            'description'=>'Facility Subsidy Fee - Diploma',
            'amount'=>200.00,
            'paid'=>100.00,
            'owed'=>100.00,
            'button'=>'y'
        ),
        '10'=>array(
            'id'=>10,
            'category_id'=>6,
            'class'=>'',
            'description'=>'Facility Subsidy Fee - Degree',
            'amount'=>200.00,
            'paid'=>100.00,
            'owed'=>100.00,
            'button'=>'y'
        )
    );*/

    //$cart = array();
    //debug($cart);
?>
<script type="text/javascript">
    var global_cart_item = <?php echo json_encode($cart); ?>;
    var service_charge = <?php echo json_encode($charge_amount); ?>;
    //console.log(global_cart_item);
</script>
<?php
    $flash_msg = $this->Session->read('Message');
    if(isset($flash_msg['flash'])){
        ?>
    <div id="loginmsg" style="">
        <?php echo $this->Message->msg('Payment Info',$this->Session->flash(),'success',true); ?>
    </div>
    <?php
    }
?>
<div id="cart" class="row-fluid">

    <?php
        if($cart){
    ?>
        <div id="cart_carousel" class="carousel slide">
            <!-- Carousel items -->
            <div class="carousel-inner">
                <div class="item active" >
                    <h4>Items To Pay For <?php echo " Academic Year ".$current_acca_year ;?></h4>
                    <div class="nano" id="fees-items">
                        <div class="content">
                            <ul class="nav nav-list">
                                <?php
                                    foreach($cart as $value){

                                        $class = $value['class'];
                                ?>
                                    <li class="<?php echo $class; ?>">
                                        <?php echo $value['description']; ?>
                                        <?php
                                            $style = 'margin-right: 100px;';
                                            if($value['button'] == 'y' && $value['owed'] > 0){
                                                $style = "";
                                        ?>
                                                <button class="btn btn-mini pull-right" data-id="<?php echo $value['id']; ?>"  data-use="<?php echo $value['trans_type_to_use']; ?>" ><i class='icon-info-sign'></i>  Select &nbsp;&nbsp;&nbsp;</button>
                                        <?php
                                            }
                                            else if($value['button'] == 'y' && $value['owed'] <= 0){
                                                $style = "";
                                        ?>
                                                <button class="btn btn-success btn-mini pull-right disabled" disabled="disabled"><i class='icon-ok'></i>  Paid &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button>
                                        <?php
                                            }
                                        ?>
                                        <span class="pull-right amounts" style="<?php echo $style; ?>">
                                            <?php
                                            if($class == 'nav-header'){
                                            ?>
                                                <span class="currency"></span>
                                            <?php
                                            }
                                            else{
                                            ?>
                                                <span class="currency">GHc</span>
                                            <?php
                                            }
                                            ?>
                                            <span class="amount"><?php echo is_numeric($value['amount']) ? $this->App->formatNumber($value['amount'],'money') : $value['amount']; ?></span>
                                            <span class="paid"><?php echo is_numeric($value['paid']) ? $this->App->formatNumber($value['paid'],'money') : $value['paid']; ?></span>
                                            <span class="owed"><?php echo is_numeric($value['owed']) ? $this->App->formatNumber($value['owed'],'money') : $value['owed']; ?></span>
                                        </span>
                                    </li>
                                <?php
                                    }
                                ?>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="item">

                    <h4>Items Selected For Payment</h4>
                    <div class="nano" id="fees-cart">
                        <div class="content">
                            <ul class="nav nav-list">

                            </ul>
                        </div>
                    </div>
                </div>
            </div>

        </div>

        <div class="span4" style="text-align: left; padding: 20px 35px;" id="total_amt_owed">
            <span class="label label-info" style="font-size: 16px; padding: 8px 15px; background-color: rgb(32, 42, 48);">Total To Pay GHc <span id="total_amt_topay">420.00</span></span>
        </div>
        <div class="span7" style="text-align: right; padding: 20px 35px;">
            <a href="javascript: void(0);" class="btn prev">&laquo; Previous</a>
            <a href="javascript: void(0);" class="btn btn-success next">Next &raquo;</a>
        </div>
        <?php
    }
    else{
    ?>
        <h3>Notifications</h3>
    <?php
        echo $this->Message->msg('Fees Notification','There are no fees setup for payment','warning');
    }
    ?>

</div>

<input type="hidden" id="do-payment-url" value="<?php echo $this->Html->url(array('controller' => 'Student', 'action' => 'do_payment')); ?>" />
<input type="hidden" id="payment-url" value="<?php echo $this->Html->url(array('controller' => 'Student', 'action' => 'payments')); ?>" />


<?php
    echo $this->Html->script('scripts/students_payment.js');
?>